/**
 * @Author: Lenovo
 * @Date: 2024/6/8 22:46
 * @description:
 */
//写一个泛型类   当中有个方法  可以求数组最大值
class Alg<E extends Comparable<E>>{
    public E FindMax(E[]array){
        E max=array[0];
        for (int i = 0; i < array.length; i++) {
            if(max.compareTo(array[i])<0){
                max=array[i];
            }
        }
        return max;
    }
}
class Alg2{
    public static<E extends Comparable<E>> E FindMax(E[]array){
        E max=array[0];
        for (int i = 0; i < array.length; i++) {
            if(max.compareTo(array[i])<0){
                max=array[i];
            }
        }
        return max;
    }
}
public class Test2 {
    public static void main(String[] args) {
        Integer[]arr={2,41,2,5,21,52,3,1,90};
        int ret=Alg2.FindMax(arr);
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        Alg<Integer>alg=new Alg<>();
        Integer[] arr={1,2,3,4,5,923,12,49};
        int ret=alg.FindMax(arr);
        System.out.println(ret);
    }
}
